﻿using DevExpress.Mvvm;
using DevExpress.Mvvm.Native;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Internal;
using OneStress.ViewModels;
using orm.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OneStress.PropertyNodes
{
    internal class ProjectNode:PropertyNode<TgsTDProject>
    {
        public ProjectNode(Guid id)
        {
            var dbContext = ServiceContainer.Default.GetService<IDisposable>("DBSerice") as OneSysDBContext;

            _current = dbContext.TgsTDProject.Where(v => v.ProjectId == id.ToString()).FirstOrDefault();
        }

        public override string Name
        {
            get
            {
                return _current?.ProjectName;
            }
            set
            {
                _current.ProjectName = value;
            }
        }

        public string Description
        {
            get
            {
                return _current?.Description;
            }
            set
            {
                _current.Description = value;
            }
        }

        public string ActivateUnitSystem
        {
            get
            {
                return
                     unitSystems[_current?.ActiveUiUnitsysId??1];
            }
            set
            {
                _current.ActiveUiUnitsysId = unitSystems.FirstOrDefault(v => v.Value==value).Key;
                   
            }
        }



        private static Dictionary<long, string> unitSystems = new Dictionary<long, string>()
        {
            { 1, "API"},
            { 2, "SI"}
        };
          
      
      
    }


}
